<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <link href="./styles.css" rel="stylesheet">
    <title>Hello World!</title>

  </head>
  <body>
    <input type="file"
           id="avatar" name="ofd文件"
           accept="ofd" onchange="handleFiles(this.files)">
    <div id="content"/>
    <script>
      function handleFiles(file) {
        console.log(file[0])
        ofd.parseOfdDocument({
          ofd: file[0],
          success(res) {
            console.log(res)
            const scale = (800 / 210).toFixed(1);
            ofd.setMaxPageScale(scale * 4);
            ofd.setPageScale(scale);
            const divs = ofd.renderOfd(res.data.ofd, 0);
            let contentDiv = document.getElementById('content');
            contentDiv.innerHTML = '';
            for (const div of divs) {
              contentDiv.appendChild(div)
            }
          }
        })
      }
    </script>
    <!-- You can also require other files to run in this process -->
    <script src="./renderer.js"></script>
    <script src="./OfdParser.js"></script>
    <script src="./FreetypeKit.js"></script>
    <script type="text/javascript" src="https://unpkg.com/ofd.js"></script>
  </body>
</html>
